//
//  UIImageView+WebImage.swift
//  XLWB
//
//  Created by MacBook on 16/7/6.
//  Copyright © 2016年 MacBook. All rights reserved.
//

import SDWebImage

extension UIImageView {

    //隔离SDWebImage 设置图像
    func da_setImage(urlString: String?, placeholderImage: UIImage?, isAvatar: Bool = false) {
    
        //处理URL
        guard let urlString = urlString,
            url = URL(string:urlString) else {
            
            //设置占位图像
                image = placeholderImage
                
                return
        }
                sd_setImage(with: url, placeholderImage: placeholderImage, options: [], progress: nil) { [weak self] (image, _, _, _) in
                    
                    //完成回调
                    if isAvatar {
                    
                    
                        self?.image = image?.cz_avatarImage(size: self?.bounds.size)
                    
                    }
    }

    }
}
